/**
 * 
 */
package org.huanglei.account.provider;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.huanglei.account.bean.Account;

/**
 * @author huanglei
 * @data Jul 12, 2012
 */
public interface DataProvider {

	public enum StaticDateFormat {
		DAY("%Y-%m-%d", 31), WEEK("%Y-%W", 52), MONTH("%Y-%m", 12), YEAR("%Y",
				1), ALL("",-1);

		private String format = null;

		private int d = 0;

		private StaticDateFormat(String format, int d) {
			this.format = format;
			this.d = d;
		}

		@Override
		public String toString() {
			return format;
		}

		public Map<String, Double> getKey() {
			Map<String, Double> map = new HashMap<String, Double>();
			for (int i = 1; i <= d; ++i) {
				map.put("" + i, 0.00);
			}
			return map;
		}
	}

	/**
	 * 保存数据
	 * 
	 * @param account
	 * @return
	 */
	public long save(Account account);

	/**
	 * 更新数据
	 * 
	 * @param account
	 * @return
	 */
	public long update(Account account);
	
	/**
	 * 根据ID删除数据
	 * @param id
	 * @return
	 */
	public long delete(int id);

	/**
	 * 获取单条数据
	 * 
	 * @param id
	 * @return
	 */
	public Account getAccount(int id);
	
	/**
	 * 获取全部数据
	 * 
	 * @return
	 */
	public List<Account> getAccounts();

	/**
	 * 获取多条数据
	 * 
	 * @param page
	 *            页
	 * @param count
	 *            条
	 * @return
	 */
	public List<Account> getAccounts(int page, int count);

	
	/**
	 * 获取指定月份统计数据
	 * @param month
	 * @return
	 */
	public Map<String, Double> getStatistics(String date,
			StaticDateFormat staticDateFormat);

	/**
	 * 获取时间统计数据
	 * 
	 * @return
	 */
	public Map<String, Double> getDateStatic(String date,
			StaticDateFormat staticDateFormat);
	
	/**
	 * 获取支付收入统计
	 * @return
	 */
	public String getTotal();

}
